<div class="section">

	<div class="section-title"><?php echo $heading_title?></div>
    
    <div class="section-content">
    	
        <form action="" method="get" id="listorder" name="listorder">
        
        	<div class="button right">
           	<a class="button" href="<?php echo $insert?>">Create new Export Voucher</a>
            <a class="button" href="index.php"><?php echo $this->document->text['button_cancel']?></a>
            </div>
          <div class="clearer">&nbsp;</div>
            <div>
                <fieldset class="fieldset1">
                	<input type="hidden" name="route" value="<?php echo $_GET['route']?>" />
                    <legend>Filter</legend>
                    <p>
                        <span class="formspacing">
                                    <label>ID :</label><input type="text" class="text" name="orderidfiter" value="<?php echo $_GET['orderidfiter']?>"/>
                        </span>
                        <span class="formspacing">
                                    <label>Created by :</label>
                            <input type="text" class="text" name="createby" value="<?php echo $_GET['createby']?>"/>
                        </span>
                        <span class="formspacing">
                                    <label>Receiver :</label>
                            <input type="text" class="text" name="supplier" value="<?php echo $_GET['supplier']?>"/>
                        </span>
                    </p>
                	<p>
                        <label>Start date :</label>
<script language="javascript">
 	$(function() {
		$("#startdate").datepicker({
				changeMonth: true,
				changeYear: true,
				dateFormat: 'dd-mm-yy'
				});
		});
 </script>
                   		<input class="text" type="text" id="startdate" name="startdate" value="<?php echo $_POST['startdate']?>" />
                    	<label>End date :</label>
<script language="javascript">
 	$(function() {
		$("#enddate").datepicker({
				changeMonth: true,
				changeYear: true,
				dateFormat: 'dd-mm-yy'
				});
		});
 </script>
                    	<input class="text" type="text" id="enddate" name="enddate" value="<?php echo $_POST['enddate']?>" />
                    
                	</p>
                    <!--<p>
                    	<label><?php echo $this->document->text['text_productname']?></label>
                        <input class="text" type="text" id="productname" name="productname" value="<?php echo $_GET['productname']?>" />
                    </p>-->
                    <p><input class="button" type="submit" name="filter" value="Filter" />&nbsp;<a class="button" href="index.php?route=addon/export">Reset</a></p>
              </fieldset>
            </div>
            <div class="sitemap treeindex">
                <table class="data-table" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr class="tr-head">
                        <th width="20%">Voucher ID</th>
                        <th width="15%">Created by</th>
                        <th width="30%">Receiver</th>
                        <th width="15%"><?php echo $this->document->text['text_date']?></th>
                        <th width="18%">&nbsp;</th>                 
                    </tr>
        
        
        <?php
            foreach($orders as $order)
            {
        ?>
                    <tr>
                        <td class="check-column"><?php echo $order['orderid']?></td>
                        <td><?php echo $order['createby']?></td>
                        <td><?php echo html_entity_decode($order['supplier'])?></td>
                        <td><?php echo $this->date->formatMySQLDate($order['orderdate'])?></td>
                        <td class="link-control">
                            <a class="button"  onClick="printVoucher('<?php echo $order['orderid']?>')">Print</a>
                            <a class="button" href="?route=addon/export&orderid=<?php echo $order['orderid']?>"><?php echo $this->document->text['button_edit']?></a>
                            <a class="button" onclick="deleteOrder('<?php echo $order['orderid']?>')">Delete</a>
                            
                        </td>
                    </tr>
        <?php
            }
        ?>
                        
                                                    
                </tbody>
                </table>
                <?php echo $pager?>
            </div>
        
        
        </form>
        
    </div>
    
</div>
<iframe id="printvoucher" src="" width="1px" height="1px"></iframe>
<script language="javascript">
$(document).ready(function() {
  	// Handler for .ready() called.
	$("#category").load("?route=common/combobox/comboboxCategory&select=<?php echo $_GET['category'][0]?>&index=0",function(){																										
		selectCategory("<?php echo $_GET['category'][0]?>","<?php echo $_GET['product'][0]?>",0)																				 
	});
});

function selectCategory(categoryid,sel,index)
{
	if(categoryid!="")
		$("#product").load("?route=common/combobox/comboboxProduct&categoryid="+categoryid+"&select="+sel+"&index=0");
	else
		$("#product").html("");
}
function getPrice(prodctid,index)
{
}

function printVoucher(orderid)
{
	document.getElementById("printvoucher").src = "?route=addon/export/view&orderid="+orderid;
}
function deleteOrder(orderid)
{
	var ans = confirm("Do you wante to delete "+orderid+"!");
	if(ans)
	{
		$.ajax({
				url: "?route=addon/order/delete&orderid="+orderid,
				cache: false,
				success: function(html)
				{
					window.location.reload();
				}
			});	
	}
}
</script>